<?php
namespace App\Tool\SMS;

/**
 * Class SmsSubmail SUBMAIL赛邮云通信平台
 * @package App\Tool\SMS
 */
class SmsSubmail
{
    /**
     * @param $mobile 手机号码
     * @param $appid    APPID
     * @param $code     短信验证码
     * @param $project  短信模板
     * @param string $url 提交地址
     * @return string json
     */
    public function send_message($mobile,$code,$appid,$project,$url='https://api.mysubmail.com/message/xsend')
    {
        $curl = curl_init();
        curl_setopt($curl, CURLOPT_URL, $url);
        curl_setopt($curl, CURLOPT_HEADER, 0);
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($curl, CURLOPT_POST, 1);

        $data = [
            'appid'     => $appid,
            'to'        => $mobile,
            'project'   => $project,
            'vars'      => '{"code":' . $code . ',"time":"60"}',
            'signature' => '5f7e5887bdf3fede9dade4a56e881f9a',//获取
        ];

        curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
        $ress = curl_exec($curl);
        curl_close($curl);
        return $ress;

        //sendMessage('13607106861', rand(100000,123456);
    }

}